home *** CD-ROM | disk | FTP | other *** search
- From: Julian F. Reschke <julian@GOEDEL.UNI-MUENSTER.DE>
- Subject: FUTIME
- Date: Thu, 25 Feb 93 23:24:33 MET DST
-
- Proposal for new Fcntl opcodes (2nd attempt)
- --------------------------------------------
-
- #define FUTIME (('F'<< 8) | 3)
- #define FTRUNCATE (('F'<< 8) | 4)
-
- These new Fcntl calls can be implemented by loadable (or builtin) file
- systems.
-
-
- Descriptions (party copied from POSIX.1 and SunOS manual pages):
- ------------
-
- struct mutimbuf {
- unsigned short actime, acdate; /* GEMDOS format */
- unsigned short modtime, moddate;
- };
-
- LONG Fcntl (WORD fh, struct mutimbuf *times, FUTIME);
-
- Sets the access and modification times of the named file.
-
- The times argument is interpreted as a pointer to a mutimbuf structure,
- and the access and modification times are set to the values contained
- in the designated structure.
-
- Returns: 0 (OK), EINVFN (opcode not available) or another error code.
-
-
-
- LONG Fcntl (WORD fh, LONG length, FTRUNCATE);
-
- This Fcntl opcode causes the file referred to by fh to have a size equal
- to length bytes. If the file was previously longer than length, the
- extra bytes are removed from the file. If it was shorter, bytes between
- the old and new lengths are read as zeroes. The file must be open for
- writing.
-
- Returns: 0 (OK), EINVFN (opcode not available) or another error code.
-
-
- Example
- -------
-
- Here's a working utime() binding from my own PureC library. It's based
- on the original MiNT lib version, so it shouldn't be a problem to
- change it back.
-
- #define FUTIME (('F'<< 8) | 3)
-
- struct mutimbuf {
- unsigned int actime, acdate; /* GEMDOS format */
- unsigned int modtime, moddate;
- };
-
- int
- utime (const char *path, const struct utimbuf *times)
- {
- int fh;
- time_t actime, modtime;
- struct mutimbuf settime;
- long ret = -32L;
-
- if (times)
- {
- actime = times->actime;
- modtime = times->modtime;
- }
- else
- {
- time (&actime);
- modtime = actime;
- }
-
- DOUnixtime2Tos (actime, &settime.acdate, &settime.actime);
- DOUnixtime2Tos (modtime, &settime.moddate, &settime.modtime);
-
- fh = (int) Fopen (path, 2);
-
- if (fh < 0)
- {
- errno = -fh;
- return -1;
- }
-
- if (DOMintVersion () > 9L)
- ret = Fcntl (fh, (long) &settime, FUTIME);
-
- if (-32L == ret)
- {
- DOSTIME D;
-
- D.date = settime.moddate;
- D.time = settime.modtime;
-
- ret = Fdatime (&D, fh, 1);
- }
-
- if ((fh = Fclose(fh)) != 0)
- {
- errno = -fh;
- return -1;
- }
-
- return 0;
- }
-
-
- Diff's for ydisk 0.6
- --------------------
-
- *** yd.c Thu Jan 28 09:53:36 1993
- --- yd.new Thu Feb 25 20:54:10 1993
- ***************
- *** 30,36 ****
- --- 30,44 ----
-
- #define TOS_ATTRIB 0x3f
-
- + #define FUTIME (('F'<< 8) | 3)
- +
- + struct mutimbuf {
- + unsigned short actime, acdate; /* GEMDOS format */
- + unsigned short modtime, moddate;
- + };
- +
- void *safety_buffer;
- +
- long safety_bufsize = SAFETY_BUFSIZE;
- long current_sbufsize = 0;
- long max_memusage = UNLIMITED;
- ***************
- *** 595,602 ****
- xattr->gid = f -> gid;
- xattr->mtime = f -> mtime;
- xattr->mdate = f -> mdate;
- ! xattr->atime = f -> mtime;
- ! xattr->adate = f -> mdate;
- xattr->ctime = f -> ctime;
- xattr->cdate = f -> cdate;
-
- --- 603,610 ----
- xattr->gid = f -> gid;
- xattr->mtime = f -> mtime;
- xattr->mdate = f -> mdate;
- ! xattr->atime = f -> atime;
- ! xattr->adate = f -> adate;
- xattr->ctime = f -> ctime;
- xattr->cdate = f -> cdate;
-
- ***************
- *** 1456,1461 ****
- --- 1464,1489 ----
- else return f->pos;
- }
-
- +
- + /* jr: new function to set access and modification times */
- +
- + static long y_utime( FILEPTR *f, struct mutimbuf *buf )
- + {
- + Y_FILE *yf;
- +
- + check_stuff();
- +
- + yf = &y_files[f->fc.index];
- +
- + yf -> mdate = buf -> moddate;
- + yf -> mtime = buf -> modtime;
- + yf -> adate = buf -> acdate;
- + yf -> atime = buf -> actime;
- +
- + return 0;
- + }
- +
- +
- long y_ioctl( FILEPTR *f, short mode, void *buf )
- {
- Y_FILE *yf;
- ***************
- *** 1474,1479 ****
- --- 1502,1509 ----
- case FIONWRITE:
- * (long *) buf = MAX_BLOCK; /* arbitrary, but this is a good value */
- return 0;
- + case FUTIME:
- + return y_utime( f, buf );
- default:
- DEBUG(("y_ioctl: mode %d not supported",mode));
- return EINVFN;
-
-
- --
- ________________ cut here _________________________
- Julian F. Reschke, Hensenstr. 142, D-W4400 Muenster
- eMail: julian@math.uni-muenster.de, jr@ms.maus.de
- ________ correct me if I'm wrong __________________
-
- !]>PKN%I6+IHN])N\>
- MPX,!["<5;U.M@ZVIM]/N(%[-J&+=K;.6L5W4<&TK\><N3=;R"X=)N6\YVG7,
- MG3)F!K[.$'UHZ;LV35/%HP=?$J*EM9]ZYA6;EORL+%<][=.>]UK=Z_K8-7H4
- M[&K?5]5H7+30N[I[:OK).HMGENTT,!D_>P&F#"3@M'#-HQ$NYNQ+TSK6(5ZU
- MHQ8 ;RR ]8?[5FR I9V[(IQBSKJ^)=L;QH\<,O:]9OY?=KEZ[48?L-'+)PQ?
- MNH>HJ'5C#<O(3^K<!80@R+A[96D%HU>NA*>@U#>(T:1'+QPW?6[.'H:EBU39
- MR(3Y[I953!=LFVE;,FHEO)IT&<-^ZT-E!R&<%C =/".$'06;6IU#*N9LG :@
- MT;ANS=TRL6L)H\<PVL%X(:*ITNJF_<^:\3;M&C$.>MF+5ZS<W4&;<5G>L632
- MM;Z=JF^<V+, FLW3=I#=1![W":NWT-Q!AN'3-X[ +; .VL&>S!&@R#163EBR
- MNVU6QM7XH' /]9%Z=M6+9DFWK'3&T>,Z["FWE6FQ;,WB;$+9PQ>.6H'L,W39
- MX21UL!O3G";IZD H.WK1U=+O(O.]TSJ"WTN&WM[N'-?O;>#4U$.MMP*+?-VO
- M>OVKEWF%%A4$HO30@HNGK5R\3PGS5ZGN7% -W=6S=O9IY#6*U3VC=NW<NVSM
- MNW=-W;IFY=,V[9L]@MGCQVT#F#1Z!^K%X"9)RR9O[QPZ<[/2MVM2T3!"NR5_
- M?[:K;X;21$=1'5HU8.F#@/KYE\/[^S462ZIH,$@ -RGQ/T"
- J /R#
-
- end
-